package com.topInterview;

import java.util.Stack;

public class leecode155_MinStack {
    private Stack<Integer> data;
    private Stack<Integer> min;

    public void push(Integer num) {
        data.push(num);
        if (min.isEmpty()) {
            min.push(num);
        } else {
            min.push(Math.min(min.peek(), num));
        }
    }


    public void pop() {
        data.pop();
        min.pop();
    }

    public int peek() {
        return data.peek();
    }

    public int getMin() {
        return min.peek();
    }
}
